<html>
<head>
<style>
a {
	text-decoration: none;
    color:black;
}
img {
  vertical-align:-3px;
}
body {
margin: 0px;
    text-align:right;
}
</style>
</head>
<body>

<script type="text/javascript">

function get(name){
   if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
      return decodeURIComponent(name[1]);
}
	var title=get('title');
	var description=get('description');
	var pubid="ra-50940ae12517d354";
	var addthisUrl="https://api.addthis.com/oexchange/0.8/";
  var extensionUrl=get('url');
	var twitter=-1;
	var addThis=-1;
	var servicesList=[
		{id:"google_plusone_share",title:"Google+"},
		{id:"twitter",title:"Tweet this"},
		{id:"facebook",title:"Facebook"},
		//{id:"linkedin",title:"Linkedin"},
		//{id:"delicious",title:"Delicious"},
		//{id:"digg",title:"Digg"},
		{id:"addthis",title:"Share..."}
	];

var getAddThis=function() {

  if(twitter==-1 || addThis==-1 ){
  return;
  }
	var finalLink='';
	for(var i= 0; i < servicesList.length; i++){
  
		finalLink+='<a href="'+addthisUrl;
		if(servicesList[i].id!="addthis"){
			finalLink+="forward/"+servicesList[i].id+"/";
		}
		finalLink+="offer?";
     if(title){
       finalLink+="title="+title;
     }
		finalLink+="&url="+extensionUrl;
		finalLink+="&pubid="+pubid;
		 if(description){
       finalLink+="&description="+description;
     }
		finalLink+='" rel="nofollow" target="_blank"';
      
    finalLink+=' title="'+servicesList[i].title+'">';
    finalLink+='<img src="http://cache.addthiscdn.com/icons/v1/thumbs/';
		finalLink+=servicesList[i].id;
		finalLink+='.gif" border="0"';
		finalLink+=' title="'+servicesList[i].title+'"';
		finalLink+='/>';
    if(servicesList[i].id=="addthis"){
      finalLink+="&nbsp;"+addThis;
    } else if(servicesList[i].id=="twitter"){
      finalLink+="&nbsp;"+twitter;
    }
    finalLink+='</a>';
		finalLink+='&nbsp;';
	}

document.body.innerHTML = finalLink + document.body.innerHTML;
}
var getTwitter=function(json) {
  twitter=json.count;
  getAddThis()
}
var getAT=function(json) {
  addThis=json.shares;
  getAddThis()
}
;
var timestamp = (new Date()).getTime()
 var script = document.createElement('script');
    script.src = 'http://cdn.api.twitter.com/1/urls/count.json?url='+extensionUrl+'&callback=getTwitter&timestamp='+timestamp ;
    script.type = 'text/javascript';
    document.body.appendChild(script);
 var script = document.createElement('script');
    script.src = 'http://api-public.addthis.com/url/shares.json?url='+extensionUrl+'&callback=getAT&timestamp='+timestamp ;
    script.type = 'text/javascript';
    document.body.appendChild(script);
</script>
</body>
</html>